package converter;

import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;
import javax.faces.convert.FacesConverter;

import entity.TestSuite;

@FacesConverter(value="testSuiteConverter")
public class TestSuiteConverter implements Converter{

	
	@Override
	public Object getAsObject(FacesContext arg0, UIComponent arg1, String value) {
		if(value!=null && value.length()>0){
		TestSuite testSuite = new TestSuite();
		testSuite.setName(value);
		return testSuite;
		}
		return null;
	}

	@Override
	public String getAsString(FacesContext arg0, UIComponent arg1, Object arg2) {
		if(arg2 != null && arg2 instanceof TestSuite) {
			return ((TestSuite)arg2).getName();
		}
		return "";
	}
}
